var table;
var expNum;
$(function(){
    table=$("#annualTable").DataTable({
        "ajax": {
            url:"../../admin/annual/Get",
            type:"POST",
            data:function(d){
                d.name=$("#search_name").val()
                d.org_type=$("#search_orgType").val()
                d.org_name=$("#search_org").val()
                d.id_type=$("#search_idType").val()
                d.id_num=$("#search_idNum").val()
                d.ca_num=$("#search_caNum").val()
                d.ca_stat=$("#search_caStat").val()
                d.annual_stat=$("#search_annualStat").val()
                d.bf_annual_stat=$("#search_annualBeforeStat").val()
                d.cred_record=$("#search_credRec").val()
                d.birth_date=$("#search_birth").val()
                d.mobile=$("#search_mobile").val()
                d.e_mail=$("#search_Email").val()
                d.pos_type=$("#search_pos").val()
                d.deal_type=$("#search_dealType").val()
                d.sex=$("#search_gender").val()

                d.dept_type=$("#search_deptType").val()
                d.dept=$("#search_dept").val()
                d.duty_type=$("#search_dutyType").val()
                d.duty=$("#search_duty").val()
            },error:function(XMLHttpRequest,textStatus,errorThrown){
                console.log("载入数据出错");
            }
        },
        "scrollX": 2900,
        "bProcessing": true,
        "bServerSide": true,
        "bPaginate": true,
        "bAutoWidth": false,
        "bInfo": true,//页脚信息
        "bFilter": false,//禁用搜索
        "bSort":false,//禁用排序
        "aLengthMenu": [100,200,300],
        "sPaginationType":'full_numbers',
        "columns": [
            {"data":"id"},
            {"data":"id"},
            {"data":"wechat_name"},
            { "data": "ca_num" },
            { "data": "name" },
            { "data": "sex" },
            { "data": "birth_date" },
            { "data": "id_type" },
            { "data": "id_num" },
            { "data": "mobile" },
            { "data": "e_mail" },
            { "data": "org_type" },
            { "data": "org_name" },
            { "data": "annual_stat" },
            { "data": "bf_annual_stat" },
            { "data": "ca_stat" },
            { "data": "qq" },
            { "data": "dept_type" },
            { "data": "dept" },
            { "data": "duty_type" },
            { "data": "duty" },
            { "data": "pos_type" },
            { "data": "deal_type" },
            { "data": "phone" },
            { "data": "cred_record" },
            { "data": "id" },
        ],
        "aoColumnDefs": [
            {"sWidth": "2500px"},
            {
                "aTargets": [ 1 ],
                "mRender": function ( data, type, full ) {
                    return '<input type="checkbox" name="tab_box" value="'+data+'">';
                }
            },
            {
                "aTargets": [ 5 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "男";break;
                        case 2:return "女";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 7 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "身份证";break;
                        case 2:return "护照";break;
                        case 3:return "港澳台证件";break;
                        case 4:return "其他";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 11 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "本币交易成员";break;
                        case 2:return "非本币交易成员";break;
                        default :return "无机构";break;
                    }
                }
            },
            {
                "aTargets": [ 13 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "未年检";break;
                        case 2:return "待审核";break;
                        case 3:return "通过";break;
                        case 4:return "不通过";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 14 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "未年检";break;
                        case 2:return "待审核";break;
                        case 3:return "通过";break;
                        case 4:return "不通过";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 15 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "有效";break;
                        case 2:return "暂停";break;
                        case 3:return "注销";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 17 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "金融市场";break;
                        case 2:return "资产管理";break;
                        case 3:return "资产负债管理";break;
                        case 4:return "中后台";break;
                        case 5:return "其他";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 19 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "公司领导";break;
                        case 2:return "部门领导";break;
                        case 3:return "主管";break;
                        case 4:return "交易员";break;
                        case 5:return "其他";break;
                        default :return " ";break;
                    }
                }
            },
            {
                "aTargets": [ 21 ],
                "mRender": function ( data, type, full ) {
                    switch (data){
                        case 1:return "交易";break;
                        case 2:return "后台结算";break;
                        case 3:return "风控";break;
                        case 4:return "合规";break;
                        case 5:return "研究";break;
                        case 6:return "销售";break;
                        case 7:return "IT系统";break;
                        case 8:return "其他";break;
                        default :return " ";break;
                    }
                }
            },
            // {
            //     "aTargets": [ 22 ],
            //     "mRender": function ( data, type, full ) {
            //         switch (data){
            //             case 1:return "资金";break;
            //             case 2:return "债券";break;
            //             case 3:return "信用衍生品";break;
            //             case 4:return "利率衍生品";break;
            //             case 5:return "其他";break;
            //             default :return " ";break;
            //         }
            //     }
            // },
            {
                "aTargets": [ 25 ],
                "mRender": function ( data, type, full ) {
                    return '<a onclick="editData(\''+full.id+'\',\''+full.ca_stat+'\',\''+full.annual_stat+'\',\''+full.name+'\'' +
                        ',\''+full.sex+'\',\''+full.birth_date+'\',\''+full.id_type+'\',\''+full.id_num+'\'' +
                        ',\''+full.ca_num+'\',\''+full.mobile+'\',\''+full.degree+'\',\''+full.highest_edu+'\'' +
                        ',\''+full.highest_sch+'\',\''+full.major+'\',\''+full.graduate_date+'\',\''+full.org_name+'\'' +
                        ',\''+full.dept+'\',\''+full.position+'\',\''+full.pos_type+'\',\''+full.deal_type+'\'' +
                        ',\''+full.duty+'\',\''+full.phone+'\',\''+full.e_mail+'\',\''+full.qq+'\',\''+full.org_addr+'\'' +
                        ',\''+full.postcode+'\',\''+full.fax+'\',\''+full.dept_type+'\',\''+full.duty_type+'\')">修改</a>' +
                        '<a style="margin-left:12px" onclick="showData(\''+full.id+'\',\''+full.ca_stat+'\',\''+full.annual_stat+'\',\''+full.name+'\'' +
                        ',\''+full.sex+'\',\''+full.birth_date+'\',\''+full.id_type+'\',\''+full.id_num+'\'' +
                        ',\''+full.ca_num+'\',\''+full.mobile+'\',\''+full.degree+'\',\''+full.highest_edu+'\'' +
                        ',\''+full.highest_sch+'\',\''+full.major+'\',\''+full.graduate_date+'\',\''+full.org_name+'\'' +
                        ',\''+full.dept+'\',\''+full.position+'\',\''+full.pos_type+'\',\''+full.deal_type+'\'' +
                        ',\''+full.duty+'\',\''+full.phone+'\',\''+full.e_mail+'\',\''+full.qq+'\',\''+full.org_addr+'\'' +
                        ',\''+full.postcode+'\',\''+full.fax+'\',\''+full.dept_type+'\',\''+full.duty_type+'\')">详情</a>' +
                        '<a style="margin-left:12px" onclick="delData(\''+full.id+'\')">删除</a>';
                }
            }

        ],
        "fnRowCallback": function (nRow, aData, iDisplayIndex) {
            $("td:first", nRow).html(iDisplayIndex + 1);
            return nRow;
        },
        "oLanguage": {
            "sProcessing": "处理中...",
            "sLengthMenu": "每页 _MENU_ 条",
            "sZeroRecords": "没有匹配结果",
            "sInfo": " _START_ 至 _END_ 项结果，共 _TOTAL_ 项",//显示第 _START_ 至 _END_ 项结果，共 _TOTAL_ 项
            "sInfoEmpty": "",//显示第 0 至 0 项结果，共 0 项
            "sInfoFiltered": "",//(由 _MAX_ 项结果过滤)
            "sInfoPostFix": "",
            "sSearch": "搜索：",
            "sUrl": "",
            "sEmptyTable": "没有数据呀!",
            "sLoadingRecords": "载入中...",
            "sInfoThousands": ",",
            "oPaginate": {
                "sFirst": "首页",
                "sPrevious": "上页",
                "sNext": "下页",
                "sLast": "末页"
            }
        },
    });

    $("#add_posType").on('change',function(e){
        var selected=$(this).children('option:selected').text();
        if(selected=="交易"){
            $("#dealType").show();
        }else{
            $("#dealType").hide();
        }
    });
    $("#add_dutType").on('change',function(e){
        var selected2=$(this).children('option:selected').val();
        if(selected2!=0){
            $("#duty").show();
        }else{
            $("#duty").hide();
        }
    });
    $("#add_depType").on('change',function(e){
        var selected3=$(this).children('option:selected').val();
        if(selected3!=0){
            $("#dept").show();
        }else{
            $("#dept").hide();
        }
    });
    importConfig($);
    importConfig2($);
})

function searchBtn(){
    table.draw();
}

function ctrlTab_box() {
    if($("input[value='ctrlTab_box']").prop("checked")){
        $("input[name='tab_box']").prop("checked",true);
    }
    else {
        $("input[name='tab_box']").prop("checked",false);
    }
}

function delData(id){
    Lobibox.confirm({
        msg: "确认要删除这条属性?",
        title:"删除属性",
        iconClass: false,
        callback: function ($this, type, ev) {
            if(type==='yes'){
                $.ajax({
                    url: "../../admin/annual/"+id+"?_csrf="+$("input[name=_csrf]").val(),
                    type: "DELETE",
                    dataType: "json",
                    success: function (data) {
                        if(data){
                            table.draw();
                            Lobibox.notify('success', {
                                msg: '删除成功',
                                sound: false
                            });
                        }else {
                            Lobibox.notify('error', {
                                msg: '删除失败',
                                sound: false
                            });
                        }
                    }, error: function () {
                    }
                });
            }
        }
    });
}

/* 批量删除 1=删除， 2=通过， 3=不通过*/
function processMore(process) {
// 判断是否至少选择一项
    var checkedNum = $("input[name='tab_box']:checked").length;
    if(checkedNum == 0) {
        alert("请选择至少一项！");
        return;
    }
// 批量选择
    var checkedList = new Array();
    $("input[name='tab_box']").each(function() {
        if($(this).is(':checked')){
            checkedList.push($(this).val());
        }
    });
    var SendData = {'Ids':checkedList.toString()
        ,'process':process }
    SendData = JsonToSecurityString(SendData)
    Lobibox.confirm({
        msg: "确认要删除这些条目?",
        title:"删除条目",
        iconClass: false,
        callback: function ($this, type, ev) {
            if(type==='yes'){
                $.ajax({
                    type: "POST",
                    url: "../../admin/annual/AnnualInformMore",
                    data: SendData,
                    success: function(data) {
                        if(data){
                            table.draw();
                            Lobibox.notify('success', {
                                msg: '操作成功',
                                sound: false
                            });
                        }else {
                            Lobibox.notify('error', {
                                msg: '操作失败',
                                sound: false
                            });
                        }
                        $("input[name='tab_box']").prop("checked", false);
                        // window.location.reload();
                    }
                });
            }
        }
    });
}
/*年检初始化  4=初始化 5=End*/
function annualInitial(process) {
    var SendData = {'process':process }
    SendData = JsonToSecurityString(SendData)
    Lobibox.confirm({
        msg: "确认是否需要进行年检操作?",
        title:"年检操作",
        iconClass: false,
        callback: function ($this, type, ev) {
            if(type==='yes'){
                $.ajax({
                    type: "POST",
                    url: "../../admin/annual/AnnualInformMore",
                    data: SendData,
                    success: function(data) {
                        if(data){
                            table.draw();
                            Lobibox.notify('success', {
                                msg: '操作成功',
                                sound: false
                            });
                        }else {
                            Lobibox.notify('error', {
                                msg: '操作失败',
                                sound: false
                            });
                        }
                    }
                });
            }
        }
    });
}

new SMValidator('#editFrom');
new SMValidator('#AddWorkExpFrom');

function modal_sub(){
    if(SMValidator.validate('#editFrom')){
        $.ajax({
            url: "../../admin/annual",
            type: "POST",
            dataType: "json",
            data: $("#editFrom").serialize(),
            beforeSend: function () {
            },
            success: function (data) {
                if(data){
                    var msg = ""
                    if($("#id").val()){
                        msg = "修改成功"
                    }else {
                        msg = "新增成功"
                    }
                    Lobibox.notify('success', {
                        msg: msg,
                        sound: false
                    });
                    $("#AnnualInformModal").modal("hide")
                    table.draw();
                }
            }, error: function () {
            }
        });
    }
}

function editData(id,annual_stat,ca_stat,name,sex,birth_date,id_type,id_num,ca_num,mobile,degree,highest_edu,highest_sch,major,graduate_date,org_name,dept,position,pos_type,deal_type,duty,phone,e_mail,qq,org_addr,postcode,fax,dept_type,duty_type) {
    $("#id").val(id);
    $("#add_annualStat").val(annual_stat);
    $("#add_caStat").val(ca_stat);
    $("#add_name").val(name);
    $("#add_sex").find("option[value='"+sex+"']").attr("selected",true);
    $("#add_birth").val(birth_date);
    $("#add_idType").find("option[value='"+id_type+"']").attr("selected",true);
    $("#add_idNum").val(id_num);
    $("#add_caNum").val(ca_num);
    $("#add_mobile").val(mobile);
    $("#add_degree").find("option[value='"+degree+"']").attr("selected",true);
    $("#add_highestEdu").find("option[value='"+highest_edu+"']").attr("selected",true);
    $("#add_highestSch").val(highest_sch);
    $("#add_major").val(major);
    $("#add_gradDate").val(graduate_date);
    $("#add_orgName").val(org_name);
    $("#add_dept").val(dept);
    $("#add_position").val(position);
    $("#add_depType").find("option[value='"+dept_type+"']").attr("selected",true).trigger('change');
    $("#add_dutType").find("option[value='"+duty_type+"']").attr("selected",true).trigger('change');
    $("#add_posType").find("option[value='"+pos_type+"']").attr("selected",true).trigger('change');
    // $("#add_dealType").find("option[value='"+deal_type+"']").attr("selected",true);
    $("#add_dealType").val(deal_type);
    $("#add_duty").val(duty);
    $("#add_phone").val(phone);
    $("#add_email").val(e_mail);
    $("#add_qq").val(qq);
    $("#add_fax").val(fax);

    $("#add_orgAddr").val(org_addr);
    $("#add_postcode").val(postcode);
    $("#AnnualInformModal").modal("show");
    //根据source（数组）和输入的值动态显示提示
    if($("#otherSch").hasClass('btn-warning')){
        $(this).trigger('click');
    }

}

//modalWorkExp
function editWorkExp() {
    $("#AnnualInformModal").modal("hide");
    $("form[id^='addWorkExpFrom']").remove();
    expNum = 1;
    var id_num = $("#add_idNum").val();
    $.ajax({
        url: "../../admin/annual/WorkExp",
        type: "GET",
        dataType: "json",
        data: {"id_num":id_num},
        success: function (data) {
            if(data!=''){
                $.each(data, function (i,item) {
                    if(i==0){
                        // $("#id2").val(item.id);
                        $("#modelIdNum").val(item.id_num);
                        $("#add_startDate").val(item.start_date);
                        $("#add_finalDate").val(item.final_date);
                        $("#add_orgFullname").val(item.org_fullname);
                        $("#add_department").val(item.department);
                        $("#add_business").val(item.business);
                        $("#add_job").val(item.job);
                    }else {
                        add_workExp();
                        // $("input[id='id2"+i+"']").val(item.id);
                        $("input[id='modelIdNum"+i+"']").val(item.id_num);
                        $("input[id='add_startDate"+i+"']").val(item.start_date);
                        $("input[id='add_finalDate"+i+"']").val(item.final_date);
                        $("input[id='add_orgFullname"+i+"']").val(item.org_fullname);
                        $("input[id='add_department"+i+"']").val(item.department);
                        $("input[id='add_business"+i+"']").val(item.business);
                        $("input[id='add_job"+i+"']").val(item.job);
                    }
                });
            }else {
                // $("#id2").val('');
                $("#modelIdNum").val(id_num);
                $("#add_startDate").val('');
                $("#add_finalDate").val('');
                $("#add_orgFullname").val('');
                $("#add_department").val('');
                $("#add_business").val('');
                $("#add_job").val('');
                console.log(data)
            }
        }, error: function () {
        }
    });
    $("#WorkExp").modal("show");
}

function workExp_sub() {
    var sendData = [];
    for(var i = 0; i<expNum; i++)
    {
        var j = 0;
        if(i == 0){
            sendData ={
                "workExpList[0].id_num": $("#AddWorkExpFrom").find('input[name="id_num"]').val(),
                // "workExpList[0].id": $("#AddWorkExpFrom").find('input[name="id"]').val(),
                "workExpList[0].start_date": $("#AddWorkExpFrom").find('input[name="start_date"]').val(),
                "workExpList[0].final_date": $("#AddWorkExpFrom").find('input[name="final_date"]').val(),
                "workExpList[0].org_fullname": $("#AddWorkExpFrom").find('input[name="org_fullname"]').val(),
                "workExpList[0].department": $("#AddWorkExpFrom").find('input[name="department"]').val(),
                "workExpList[0].business": $("#AddWorkExpFrom").find('input[name="business"]').val(),
                "workExpList[0].job": $("#AddWorkExpFrom").find('input[name="job"]').val()
            };
        }
        if($("form[id='addWorkExpFrom"+i+"']").length >0){
            j++;
            sendData["workExpList["+j+"].id_num"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="id_num"]').val();
            // sendData["workExpList["+j+"].id"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="id"]').val();
            sendData["workExpList["+j+"].start_date"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="start_date"]').val();
            sendData["workExpList["+j+"].final_date"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="final_date"]').val();
            sendData["workExpList["+j+"].org_fullname"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="org_fullname"]').val();
            sendData["workExpList["+j+"].department"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="department"]').val();
            sendData["workExpList["+j+"].business"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="business"]').val();
            sendData["workExpList["+j+"].job"] = $("form[id='addWorkExpFrom"+i+"']").find('input[name="job"]').val();
        }
    }
    //
    // $("form[id^='addWorkExpFrom']").each(function (i) {
    //
    // });
    sendData = JsonToSecurityString(sendData);
    console.log(sendData)
    if(SMValidator.validate('#AddWorkExpFrom')){
        $.ajax({
            url: "../../admin/annual/newWorkExp",
            type: "POST",
            data: sendData,
            success: function (data) {
                if(data){
                    var msg = ""
                    if($("#id").val()){
                        msg = "修改成功"
                    }else {
                        msg = "新增成功"
                    }
                    Lobibox.notify('success', {
                        msg: msg,
                        sound: false
                    });
                    $("#WorkExp").modal("hide");
                    $("#AnnualInformModal").modal("show");

                }
            }, error: function () {
            }
        });
    }
}

function del_workExp(num) {
    if( num >= 1 ) {
        $("form[id=addWorkExpFrom" + num + "]").remove();
    }
}

function add_workExp() {
    $("#workExpGrp").append('<form class="form-horizontal" id="addWorkExpFrom' + expNum + '"> ' +
        '<div id="workExpGrp' + expNum + '" class="box-body"> ' +
        '<div class="form-group"> ' +
        '<label class="col-sm-2 control-label">工作经历</label> ' +
        '<button type="button" class="close" value="' + expNum + '"  onclick="del_workExp($(this).val())" aria-label="Close">' +
        '<span aria-hidden="true">&times;</span></button>' +
        '<div class="col-sm-10"> ' +
        '<input type="hidden" id="modelIdNum' + expNum + '" name="id_num"> ' +
        // '<input type="hidden" id="id2' + expNum + '" name="id"> ' +
        '</div> ' +
        '</div> ' +
        '<div class="form-group"> ' +
        '<label for="add_startDate' + expNum + '" class="col-sm-2 control-label">开始时间</label> ' +
        '<div class="col-sm-10"> ' +
        '<input type="date" class="form-control" id="add_startDate' + expNum + '" data-rule="required(开始时间必须填写)" name="start_date" placeholder="开始时间"> ' +
        '</div> ' +
        '</div> ' +
        '<div class="form-group"> ' +
        '<label for="add_finalDate' + expNum + '" class="col-sm-2 control-label">截止时间</label> ' +
        '<div class="col-sm-10"> ' +
        '<input type="date" class="form-control" id="add_finalDate' + expNum + '" name="final_date" placeholder="截止时间（不填代表至今）"> ' +
        '</div> ' +
        '</div> ' +
        '<div class="form-group"> ' +
        '<label for="add_orgFullname' + expNum + '" class="col-sm-2 control-label">机构全称</label> ' +
        '<div class="col-sm-10"> ' +
        '<input type="text" class="form-control" id="add_orgFullname' + expNum + '" name="org_fullname" placeholder="机构全称"> ' +
        '</div> ' +
        '</div> ' +
        '<div class="form-group"> ' +
        '<label for="add_department' + expNum + '" class="col-sm-2 control-label">所属部门</label> ' +
        '<div class="col-sm-10"> ' +
        '<input type="text" class="form-control" id="add_department' + expNum + '" name="department" placeholder="所属部门"> ' +
        '</div> ' +
        '</div> ' +
        '<div class="form-group"> ' +
        '<label for="add_business' + expNum + '" class="col-sm-2 control-label">从事业务</label> ' +
        '<div class="col-sm-10"> ' +
        '<input type="text" class="form-control" id="add_business' + expNum + '" name="business" placeholder="从事业务"> ' +
        '</div> ' +
        '</div> ' +
        '<div class="form-group"> ' +
        '<label for="add_job' + expNum + '" class="col-sm-2 control-label">职务</label> ' +
        '<div class="col-sm-10"> ' +
        '<input type="text" class="form-control" id="add_job' + expNum + '" name="job" placeholder="职务"> ' +
        '</div> ' +
        '</div> ' +
        '</div> ' +
        '</form>');
    expNum++;
}

/**
 * @return {string}
 */
function JsonToSecurityString(SendData) {
    var eachData = {};
    eachData["_csrf"]=$("input[name=_csrf]").val();
    for(var i in SendData){
        eachData[i]=SendData[i];
    }
    var sendStr = "";
    for(var key in eachData){
        if (key=="_csrf"){
            sendStr += key + '=' + eachData[key];
        }else{
            sendStr += '&' + key + '=' + eachData[key];
        }
    }
    return sendStr;
}
//excel 导入导出
function annualImport(){
    $("#annual-modal-form").modal("show");
}
function importConfig($) {
    $("#importAnnualFile").ace_file_input({
        no_file:'选择文件 ...',
        btn_choose:'选择',
        btn_change:'选择',
        droppable:false,
        thumbnail:false, //| true | large
        whitelist:'xlsx|xls'
    }).on('change', function(){
        var names=$(this).data('ace_input_files')[0].name.split(".")
        if(names[names.length-1]!=="xlsx"&&names[names.length-1]!=="xls"){
            alert("只接受xlsx或xls文件")
            // return
        }
    });
}
function submitAnnualFile() {
    $("#annualFileForm").ajaxSubmit({
        type: 'POST',
        dataType: "json",
        url:"../../admin/annual/import",
        success: function(data){
            if(data){
                Lobibox.notify('success', {
                    msg: "导入成功",
                    sound: false
                });
                window.location.reload();
            }else {
                Lobibox.notify('error', {
                    msg: "导入失败",
                    sound: false
                });
            }
            $("#annual-modal-form").modal("hide")
        },
        error: function(XmlHttpRequest, textStatus, errorThrown){
            alert( "error");
        }
    })
}

function showData(id,annual_stat,ca_stat,name,sex,birth_date,id_type,id_num,ca_num,mobile,degree,highest_edu,highest_sch,major,graduate_date,org_name,dept,position,pos_type,deal_type,duty,phone,e_mail,qq,org_addr,postcode,fax,dept_type,duty_type) {
    $("#show_name").text(name);
    if (sex == '1') {$('#show_sex').text("男");}
    else if (sex == '2') {$("#show_sex").text("女");}

    $("#AnnualInformDetailModal").modal("show");
}

function exportExcel(){
    window.location.href="../../admin/annual/exportEmail.html";
}
function exportAnnual() {
    window.location.href="../../admin/annual/exportAnnual.html";
}
function MsgSMS() {
    $("#Msg").text("");
    $("#MsgSMS").modal("show");
}
function ResTempSMS() {
    $("#ResTemp").text("");
    $("#ResSMS").modal("show");
}
function MsgSMS_sub() {
    // var Msg = $("#Msg").val();
    // console.log(Msg);
    $.ajax({
        url: "../../admin/annual/restful/sendSMS",
        type: "POST",
        data: $("#SMSForm").serialize(),
        success: function (data) {
            console.log(data);
            if(data){
                Lobibox.notify('success', {
                    msg: "短信发送成功",
                    sound: false
                });
            }
            else{
                Lobibox.notify('success', {
                    msg: "短信发送失败",
                    sound: false
                });
            }
            $("#MsgSMS").modal("hide");
        }, error: function () {
        }
    });
}

function EmailModal() {
    $("#MailMsg").val("");
    $("#MailModal").modal("show");
}

function importConfig2($) {
    $("#attachment").ace_file_input({
        no_file:'选择文件 ...',
        btn_choose:'选择',
        btn_change:'选择',
        droppable:false,
        thumbnail:false, //| true | large
        whitelist:'xlsx|xls|doc|docx'
    }).on('change', function(){
        var names=$(this).data('ace_input_files')[0].name.split(".")
        if(names[names.length-1]!=="xlsx"&&names[names.length-1]!=="xls"
            &&names[names.length-1]!=="doc"&&names[names.length-1]!=="docx"){
            alert("文件格式有问题")
            // return
        }
    });
}

function sendEmail() {//这部分需要验证
    $.ajax({
        url: "../../admin/annual/restful/sendMail",
        type: "POST",
        data: {},
        success: function (data) {
            if(data){
                Lobibox.notify('success', {
                    msg: "邮件发送成功",
                    sound: false
                });
            }
            else{
                Lobibox.notify('success', {
                    msg: "邮件发送失败",
                    sound: false
                });
            }
        }, error: function () {
        }
    });
}

function ResTemp_sub() {
    var Msg = $("#ResTemp").text();
    $.ajax({
        url: "../../admin/annual/restful/ResTemp",
        type: "POST",
        data: {"ResTemp":Msg}
    });
    $("#ResSMS").modal("hide");
}